#ifndef NNE_MEM_DRAM_H_
#define NNE_MEM_DRAM_H_

#include <map>
#include <memory>
#include "type.h"
#include "util.h"
#include "mem_if.h"

class Dram : public MemInterface{
public:
    Dram(unsigned int page_size, u8 default_value = 0xFF);
    void write_mem(u64 dst, void* src, u64 length);
    void read_mem(void* dst, u64 src, u64 length);
    //void to_sram(u64 dst, void* src,u64 length);
    //void from_sram(void* dst, u64 src,u64 length);
    ~Dram(){}
private:
    struct Page{
        u8* Memory_page;
        Page(unsigned int page_size){Memory_page = new u8[page_size];}
        ~Page(){delete [] Memory_page;}
    };
    using DramMapType = std::map<u64, std::unique_ptr<Page>>;
    inline DramMapType::iterator find_page(u64 page_key);
    Dram(const Dram &) = delete;
    Dram &operator=(const Dram &) = delete;
    unsigned int PageSize;
    unsigned char PageSizeBit;
    u8 DefaultValue;
    DramMapType DramMap;
};

#endif
